import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringExtractor {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter source code (type 'exit' to finish):");

        StringBuilder sourceCodeBuilder = new StringBuilder();
        String line;

        // 读取输入直到用户输入"exit"
        while (!(line = scanner.nextLine()).equals("exit")) {
            sourceCodeBuilder.append(line);
        }

        scanner.close();

        String sourceCode = sourceCodeBuilder.toString();
        Pattern pattern = Pattern.compile("(\"(?:[^\"\\\\]|\\\\.)*\")"); // 匹配字符串字面量
        Matcher matcher = pattern.matcher(sourceCode);

        // 输出提取的字符串
        while (matcher.find()) {
            String matchedString = matcher.group();
            // 去除转义字符
            String unescapedString = unescapeString(matchedString);
            System.out.println(unescapedString);
        }
    }

    private static String unescapeString(String str) {
        // 如果字符串以转义的双引号结尾，先移除它
        if (str.endsWith("\\\"")) {
            str = str.substring(0, str.length() - 2) + "\"";
        }
        // 去除其他转义字符
        return str.replaceAll("\\\\(.)", "$1");
    }
}